home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 4 / BBS in a Box - Macintosh - Volume IV (January 1992) (BBS in a Box).iso / Files / Prog / D-G / FSREADLINE.P < prev    next >
Encoding:
Text File  |  1988-10-13  |  1.1 KB  |  43 lines  |  [TEXT/MACA]

  1. type
  2.   Buffer        = packed array[0..254] of char;
  3.   BufferPtr     = ^Buffer;
  4.  
  5.  
  6. function FSReadLine(refNum: Integer;request:Longint;var count: Longint;
  7.                     abuffer:BufferPtr):OSErr;
  8.  
  9. {Reads in one line of text from a textfile and puts the chars in aBuffer
  10.  Can be used for reading text in a desk accesory}
  11. var
  12.   iopb      : ParamBlockRec;
  13.   result    : OSErr;
  14.   
  15. begin
  16.   iopb.ioResult := noErr;
  17.   iopb.ioRefNum := refNum;
  18.   iopb.ioBuffer := Pointer(abuffer);
  19.   iopb.ioReqCount := request;
  20.   iopb.ioActCount := 0;
  21.   iopb.ioPosMode := $0d80;
  22.   iopb.ioPosOffset := 0;
  23.   FSReadLine := PBRead(@iopb,False);
  24.   count := iopb.ioActCount;
  25. end;
  26.  
  27. var
  28.   theErr        : Integer;    {If an error does occur       }
  29.   bytesRead     : LongInt;    {Number of bytes actually read}
  30.  
  31.  
  32. begin
  33.   {Pass to FSReadLine:
  34.      fRef      = file reference (integer)
  35.      bytes     = number of bytes to attempt to read (longInt)
  36.   Get back:
  37.      theErr    = file error (integer)
  38.      bytesRead = bytes actually read (longInt)
  39.      commRd    = buffer of chars (BufferPtr)}
  40.      
  41.   theErr := FSReadLine(fRef,255,bytesRead,commRd);
  42. end.